// 保存组件参数
import { BusinessEnum } from '@/enum/ApiEnum'

import { PeaceColumn } from '@/components/type/PeaceColumn'

export class SaveConfig {
  // 私有属性
  private _type: BusinessEnum
  private _columns: Array<PeaceColumn>
  private _title?: string
  private _formData?: Record<string, any>
  private _dialogWidth?: string

  constructor(
    type: BusinessEnum,
    columns: Array<PeaceColumn>,
    title?: string,
    formData?: Record<string, any>,
    dialogWidth?: string,
  ) {
    this._type = type
    this._columns = columns
    this._title = title
    this._formData = formData
    this._dialogWidth = dialogWidth
  }

  // getters
  get type(): BusinessEnum {
    return this._type
  }

  get columns(): Array<PeaceColumn> {
    return this._columns
  }

  get title(): string {
    return this._title || '保存'
  }

  get formData(): Record<string, any> | undefined {
    return this._formData
  }

  get dialogWidth(): string | undefined {
    return this._dialogWidth
  }

  // setters
  set type(value: BusinessEnum) {
    this._type = value
  }

  set columns(value: Array<PeaceColumn>) {
    this._columns = value
  }

  set title(value: string) {
    this._title = value
  }

  set formData(value: Record<string, any> | undefined) {
    this._formData = value
  }

  set dialogWidth(value: string | undefined) {
    this._dialogWidth = value
  }
}
